﻿
<div class="ph-tabs">
    <ul>
        <li class="k-state-active">数据采集进度</li>
    </ul>
    <div>
        <div class="k-block divToolbar">
            <div style="display: inline-block;">
                <select id="selArchive" style="width: 400px"></select>
            </div>
            <div style="display: inline-block;">
                <select id="selFinished">
                    <option value="">全部</option>
                    <option value="true">已完成</option>
                    <option value="false" selected="selected">未完成</option>
                </select>
            </div>
            <span class="k-textbox k-space-right">
                <input type="text" placeholder="请输入班级名称" id="txtKey" />
                <a href="javascript:Filter()" class="k-icon k-i-search">&nbsp;</a>
            </span>
        </div>
        <div id="grid_sample_group" style="text-align: center"></div>
    </div>
</div>

<script class="init">
    var his = "@(ViewBag.History)" == "True";
    if (his)
        LocatedMenu("历年报告", "采集报告");
    else
        LocatedMenu("数据分析", "进度统计");

    $("#selArchive").kendoDropDownList({
        dataTextField: "Title",
        dataValueField: "Guid",
        dataSource: Whale.dataSource({
            url: "/Achievements/Archive/Gets",
            getParameters: function () {
                return {
                    aType: 2,
                    expired:his
                }
            }
        }),
        dataBound: function (e) {
            if (this.dataSource.data().length == 0) {
                this.setDataSource(new kendo.data.DataSource({
                    data: [{ Title: "暂无档案", Guid: "" }]
                }));
            }
        },
        change: function (e) {
            Filter();
        }
    });
    $("#selFinished").kendoDropDownList({
        change: function (e) {
            Filter();
        }
    });
    function Filter() {
        $("#grid_sample_group").data("kendoGrid").dataSource.page(0);
    }

    var sGuid = "@PH.Web.Global.WebContext.CurrentSchool.Guid";
</script>

<script class="grid">
    $(function () {
        $("#grid_sample_group").kendoGrid({
            columns: [{
                title: "班级名称",
                field: "ClassName",
                width: 150
            }, {
                title: "人数",
                field: "Total",
                width: 70
            }, {
                title: "应测",
                field: "Due",
                width: 70
            }, {
                title: "已测",
                field: "Sample",
                width: 70
            }, {
                title: "未测",
                field: "Balance",
                width: 70
            }, {}],
            dataSource: Whale.dataSource({
                url: "/Analyses/ANS/GetS4SampleGroup",
                getParameters: function () {
                    var parameters = {
                        aGuid: $("#selArchive").data("kendoDropDownList").value(),
                        sGuid: sGuid,
                        key: $.trim($("#txtKey").val()),
                        history:his
                    };
                    if ($("#selFinished").data("kendoDropDownList").value() != "") {
                        parameters = $.extend(parameters, { finished: $("#selFinished").data("kendoDropDownList").value() });
                    }
                    return parameters;
                },
                pageSize: 15

            }),
            pageable: {
                messages: {
                    empty: "暂无数据"
                }
            },
            dataBound: function (e) {
                //让表头居中
                $("th.k-header").attr("style", "text-align:center; font-weight:bold;");
            },
            detailTemplate: kendo.template($("#detailsTemplate").html()),
            detailInit: detailInit
        });
    });
</script>

<script type="text/x-kendo-template" id="detailsTemplate">
    <div class="grid_sample_group_details"></div>
</script>

<script class="detail_init">
    function detailInit(e) {
        var detailRow = e.detailRow;
        detailRow.find(".grid_sample_group_details").kendoGrid({
            columns: [{
                title: "项目",
                field: "SubjectName",
                width: 211
            }, {
                title: "应测",
                field: "Due",
                width: 70
            }, {
                title: "已测",
                field: "Sample",
                width: 70
            }, {
                title: "未测",
                field: "Balance",
                width: 70
            }, {}],
            dataSource: Whale.dataSource({
                url: "/Analyses/ANS/GetS4Sample",
                getParameters: function () {
                    return {
                        aGuid: $("#selArchive").data("kendoDropDownList").value(),
                        sGuid: sGuid,
                        classID: e.data.ClassID,
                        history:his
                    };
                }
            }),
            pageable:false,
            dataBound: function (e) {
                //让表头居中
                $("th.k-header").attr("style", "text-align:center; font-weight:bold;");
            },
        });
    }
</script>



